package com.ruoyi.web.controller.business;

import java.util.List;

import com.ruoyi.business.domain.ImUser;
import com.ruoyi.business.service.IImUserService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.AdminBaseController;
import com.ruoyi.common.core.domain.$;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 即时通讯用户Controller
 *
 * @author ruoyi
 * @date 2025-07-11
 */
@RestController
@RequestMapping("/business/imUser")
public class ImUserControllerAdmin extends AdminBaseController
{
    @Autowired
    private IImUserService imUserService;

    /**
     * 查询即时通讯用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:imUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImUser imUser)
    {
        startPage();
        List<ImUser> list = imUserService.selectImUserList(imUser);
        return getDataTable(list);
    }

    /**
     * 导出即时通讯用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:imUser:export')")
    @Log(title = "即时通讯用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImUser imUser)
    {
        List<ImUser> list = imUserService.selectImUserList(imUser);
        ExcelUtil<ImUser> util = new ExcelUtil<ImUser>(ImUser.class);
        util.exportExcel(response, list, "即时通讯用户数据");
    }

    /**
     * 获取即时通讯用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:imUser:query')")
    @GetMapping(value = "/{id}")
    public $ getInfo(@PathVariable("id") Long id)
    {
        return success(imUserService.selectImUserById(id));
    }

    /**
     * 新增即时通讯用户
     */
    @PreAuthorize("@ss.hasPermi('business:imUser:add')")
    @Log(title = "即时通讯用户", businessType = BusinessType.INSERT)
    @PostMapping
    public $ add(@RequestBody ImUser imUser)
    {
        return toAjax(imUserService.insertImUser(imUser));
    }

    /**
     * 修改即时通讯用户
     */
    @PreAuthorize("@ss.hasPermi('business:imUser:edit')")
    @Log(title = "即时通讯用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public $ edit(@RequestBody ImUser imUser)
    {
        return toAjax(imUserService.updateImUser(imUser));
    }

    /**
     * 删除即时通讯用户
     */
    @PreAuthorize("@ss.hasPermi('business:imUser:remove')")
    @Log(title = "即时通讯用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public $ remove(@PathVariable Long[] ids)
    {
        return toAjax(imUserService.deleteImUserByIds(ids));
    }
}
